package com.shanshi.activity.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.shanshi.activity.R;
import com.shanshi.activity.request.EssayInfo;
import com.shanshi.activity.tool.TextCircleView;

import java.util.List;

/**
 * Created by cz on 2017/3/20.
 */

public class HeadPicAdapter extends RecyclerView.Adapter<HeadPicAdapter.MyheadViewHolder> {
    private Context context;
    private List<EssayInfo.DataBean.ArticlePraiseUserBean> list;

    public HeadPicAdapter(Context context, List<EssayInfo.DataBean.ArticlePraiseUserBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public MyheadViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_headpic, parent, false);

        return new MyheadViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MyheadViewHolder holder, int position) {
        holder.imageView.setText(list.get(position).getName().charAt(0) + "");
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    class MyheadViewHolder extends RecyclerView.ViewHolder {
        TextCircleView imageView;

        public MyheadViewHolder(View itemView) {
            super(itemView);
            imageView = (TextCircleView) itemView.findViewById(R.id.img_headpic);
        }
    }
}
